﻿package com.cilico.single.components;


import android.content.Context;
import android.graphics.Bitmap;
import android.widget.LinearLayout;

import com.cilico.single.R;
import com.cilico.single.utils.Constant;
import com.cilico.single.utils.ConstantRepository;
import com.cilico.single.utils.Utils;
import com.cilico.single.view.BaseView;

/**
 * 状态栏
 * @author lv.xiangan
 *
 */
public class StatusBar extends LinearLayout {
	public static String[] ARRVALUE;
	public TabItem t_;
	public BaseView bv_;

	public StatusBar(Context context, String[] labels, Bitmap[] bitmaps, Bitmap[] bitmapsD) {
		super(context);
		bv_ = (BaseView) context;
		if (labels == null) {
			return;
		}
		try {
			addTab(context, labels, bitmaps, bitmapsD, null, null);
		} catch (Exception e) {
			Utils.printException(e);
		}
	}

	void addTab(Context context, String[] labels, Bitmap[] bitmaps, Bitmap[] bitmapsD, Bitmap on, Bitmap off) throws Exception {
		Bitmap statusArr = null;
		statusArr = ConstantRepository.decodeBitmap(bv_.getResources(), R.drawable.status_arrow);
		t_ = new TabItem(context, labels, bitmaps, bitmapsD, on, off, Constant.statusBackground_, statusArr);
		if (null != bitmaps) {
			t_.isImgUnit_ = true;
		} else {
			t_.isImgUnit_ = false;
		}
		t_.setCurrentTab(TabItem.currentTab_);
		t_.reculculateMaxUnitNum();
		t_.height_ = Constant.statusBackground_.getHeight();
		t_.lengthBitmap_ = statusArr.getWidth() >> 1;
		if (statusArr != null && !statusArr.isRecycled()) {
			statusArr.recycle();
		}
		statusArr = null;
		this.addView(t_);
	}
}
